
import * as types from '../../mutation-types/user-control/index';

const state = {
    userDatas: [],
    currentPage: 1,
    pageSizes: [10,20,50],
    pageSize: 50,
    total: 0,
    editIndex: null,
    departmentList: [],
    roleList: [],
    axiosCode: -1,
    jobList: [],
    jobName: ''
}

const mutations = {
    dealUserData (state,{data}) {
        state.userDatas = data
    },
    dealTotal(state,{total}) {
        state.total = total
    },
    dealPageSize(state,{pageSize}) {
        state.pageSize = pageSize
    },
    dealCurrentPage(state,{index}) {
        state.currentPage = index
    },
    delUserData(state , {index}){
        state.userDatas.splice(index,1);
    },
    dealEditIndex(state,{index}) {
        state.editIndex = index
    },
    dealDepartmentList(state,{data}) {
        state.departmentList = data
    },
    dealRoleList(state,{data}) {
        state.roleList = data
    },
    dealUserStatus(state,{preload}) {
        state.userDatas[preload.index].status = preload.status
    },
    dealAxiosCode(state,{val}) {
        state.axiosCode = val
    },
    dealJobList(state,{data}) {
        state.jobList = data
    },
    dealJobName(state,{data}) {
        state.jobName = data
    }
}

export default {
    state,
    mutations
}